package com.by.sbdemoby.handler;

import com.by.sbdemoby.model.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @auth wzy
 * @date 2023/12/9 11:31
 */
@RestControllerAdvice
public class BaseExceptionHandler {

    /**
     * @param e 异常
     * @return 统一结果返回
     */
    @ExceptionHandler(ArithmeticException.class)
    public AjaxResult exception(ArithmeticException e) {
        return AjaxResult.error(e.getMessage());
    }

    /**
     *
     * @param e 异常
     * @return 统一结果返回
     */
    @ExceptionHandler(NullPointerException.class)
    public AjaxResult exception(NullPointerException e) {
        return AjaxResult.error(e.getMessage());
    }
}
